package com.ele.server.dao;

import com.ele.model.AppUser;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: wayfinder
 * Date: 04.09.12
 * Time: 0:56
 * To change this template use File | Settings | File Templates.
 */
public class AppUserDAO extends GenericDAO<AppUser> {

    public AppUserDAO() {
        super(AppUser.class);
    }

    public AppUser find(String email, String password) {
        List resultList = em.createQuery("SELECT e FROM AppUser e WHERE e.email = :email AND e.password = :password")
                .setParameter("email", email)
                .setParameter("password", password)
                .getResultList();
        return resultList.isEmpty() ? null : (AppUser) resultList.get(0);
    }
}
